﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Spanner
{
    public partial class UI
    {
        public sealed class IntervalHandle { }

        public sealed class TimeoutHandle { }

        /// <summary>
        /// ClearInterval(x) is equivalent to clearInterval(x) in JavaScript.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static Act ClearInterval(Expr<IntervalHandle> x)
        {
            return JSAct("clearInterval(#)", x);
        }

        /// <summary>
        /// SetInterval(f, ms) is equivalent to setInterval(f, ms) in JavaScript.
        /// </summary>
        /// <param name="f"></param>
        /// <param name="ms"></param>
        /// <returns></returns>
        public static Expr<IntervalHandle> SetInterval(Expr<Fn<Act>> f, Expr<int> ms)
        {
            return JSExpr<IntervalHandle>("setInterval(#, #)", f, ms);
        }

        /// <summary>
        /// ClearTimeout(x) is equivalent to clearTimeout(x) in JavaScript.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static Act ClearTimeout(Expr<TimeoutHandle> x)
        {
            return JSAct("clearTimeout(#)", x);
        }

        /// <summary>
        /// SetTimeout(f, ms) is equivalent to setTimeout(f, ms) in JavaScript.
        /// </summary>
        /// <param name="f"></param>
        /// <param name="ms"></param>
        /// <returns></returns>
        public static Expr<TimeoutHandle> SetTimeout(Expr<Fn<Act>> f, Expr<int> ms)
        {
            return JSExpr<TimeoutHandle>("setTimeout(#, #)", f, ms);
        }
    }
}
